#endif
static char *opt_output_path;
+static char *opt_subpath;
static gboolean opt_no_xattrs;
static GOptionEntry options[] = {
{ "no-xattrs", 0, 0, G_OPTION_ARG_NONE, &opt_no_xattrs, "Skip output of extended attributes", NULL },
+ { "subpath", 0, 0, G_OPTION_ARG_STRING, &opt_subpath, "Checkout sub-directory PATH", "PATH" },
{ "output", 'o', 0, G_OPTION_ARG_STRING, &opt_output_path, "Output to PATH ", "PATH" },
{ NULL }
};
gboolean ret = FALSE;
const char *rev;
g_autoptr(GFile) root = NULL;
+ g_autoptr(GFile) subtree = NULL;
g_autofree char *commit = NULL;
g_autoptr(GVariant) commit_data = NULL;
struct archive *a;
opts.timestamp_secs = ostree_commit_get_timestamp (commit_data);
- if (!ostree_repo_export_tree_to_archive (repo, &opts, (OstreeRepoFile*)root, a,
+ if (opt_subpath)
+ subtree = g_file_resolve_relative_path (root, opt_subpath);
+ else
+ subtree = g_object_ref (root);
+
+ if (!ostree_repo_export_tree_to_archive (repo, &opts, (OstreeRepoFile*)subtree, a,
cancellable, error))
goto out;
setup_test_repository "archive-z2"
-echo '1..2'
+echo '1..3'
$OSTREE checkout test2 test2-co
$OSTREE commit --no-xattrs -b test2-noxattrs -s "test2 without xattrs" --tree=dir=test2-co
(cd t && tar xf ../test2.tar)
${CMD_PREFIX} ostree --repo=repo diff --no-xattrs test2-noxattrs ./t > diff.txt
assert_file_empty diff.txt
-rm test2.tar diff.txt t -rf
echo 'ok export gnutar diff (no xattrs)'
+cd ${test_tmpdir}
+${OSTREE} 'export' test2-noxattrs --subpath=baz -o test2-subpath.tar
+mkdir t2
+(cd t2 && tar xf ../test2-subpath.tar)
+${CMD_PREFIX} ostree --repo=repo diff --no-xattrs ./t2 ./t/baz > diff.txt
+assert_file_empty diff.txt
+
+echo 'ok export --subpath gnutar diff (no xattrs)'
+
+rm test2.tar test2-subpath.tar diff.txt t t2 -rf
+
cd ${test_tmpdir}
${OSTREE} 'export' test2 -o test2.tar
${OSTREE} commit -b test2-from-tar -s 'Import from tar' --tree=tar=test2.tar